<%--
  Created by IntelliJ IDEA.
  User: zhangyuan
  Date: 2020-04-26
  Time: 14:06
  To change this template use File | Settings | File Templates.
--%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <title><fmt:message code="meet.th.ConferenceApplication" /></title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="/css/meeting/index.css">
    <link rel="stylesheet" type="text/css" href="../../lib/fullcalendar/css/fullcalendar.css"/>
    <link rel="stylesheet" type="text/css" href="../../lib/fullcalendar/css/fullcalendar.print.css"/>
    <link rel="stylesheet" href="/lib/layer/skin/default/layer.css">
    <link rel="stylesheet" href="/lib/pagination/style/pagination.css">
    <link rel="stylesheet" type="text/css" href="/lib/layui/layui/css/layui.css"/>
    <script type="text/javascript" src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.all.js"></script>
    <style>
        .equip tbody td{
            text-align: center;
        }
        .equipSpan{
            background-color:#00a2d4;
        }
        .equip {
            width: 77%;
            margin: 20px auto;
        }
        table tbody td{
            overflow: hidden;
            text-overflow:ellipsis;
            white-space: nowrap;
            padding:0;
        }
        .head .headli{
            width:94px;
        }

        .pagediv{
            margin: 0 auto!important;
        }
        .table tr td:first-of-type{
            text-align: right;
        }
        .layui-layer-btn {
            text-align: center!important;
        }
        .layui-laydate-content td, .layui-laydate-content th{
            font-size: 14px;
            line-height: normal;
        }
    </style>
    <%--<link rel="stylesheet" href="/css/base.css">--%>
    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="../../lib/fullcalendar/moment.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery-1.8.3.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.fileupload.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../lib/fullcalendar/fullcalendar.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../lib/fullcalendar/jquery-ui.custom.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../lib/fullcalendar/zh-cn.js" type="text/javascript" charset="utf-8"></script>
    <script src="../lib/layer/layer.js?20201106" type="text/javascript" charset="utf-8"></script>
    <script src="/js/base/base.js?20190927.1"></script>
    <script src="/lib/layDate-v5.0.9/laydate/laydate.js"></script>
    <script src="/js/jquery/jquery.cookie.js"></script>
    <script src="/lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/js/ajaxupload.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jquery.form.min.js"></script>
    <script src="/lib/jquery.jqprint-0.3.js"></script>
    <script src="../js/webOffice/fileShow.js" type="text/javascript" charset="utf-8"></script>
    <style>
        .typeBtn{
            float: right;
            margin: 5px 5px;
            width: 60px;
            height: 28px;
            line-height: 38px;
            color: #fff;
            border: 1px solid #ebebeb;
            outline: none;
            font-size: 14px;
            border-radius: 5px;
            line-height: 28px;
            cursor: pointer;
        }
        .M-box3 .active{
            margin: 0px 3px;
            width: 29px;
            height: 29px;
            line-height: 29px;
            background: #2b7fe0;
            font-size: 12px;
            border: 1px solid #2b7fe0;
            color:#fff;
            text-align:center;
            display: inline-block;
        }
        .M-box3 a{
            margin: 0 3px;
            width: 29px;
            height: 29px;
            line-height: 29px;
            font-size: 12px;
            display: inline-block;
            text-align:center;
            background: #fff;
            border: 1px solid #ebebeb;
            color: #bdbdbd;
            text-decoration: none;
        }
        .jump-ipt{
            float: left;
            width: 30px;
            height: 30px;
        }
        .span_td{
            width: 130px;
            text-align: right;
        }
        .table{
            width: 90%;
            margin: 10px auto;
        }
        .div_tr input{
            text-indent: 5px;
        }

        .one {
            border-radius: 20px !important;
        }

        .fc-header-left, .fc-header-right {
            padding: 10px 18px !important;
            box-sizing: border-box;
        }

        .fc-header-left .fc-button, .fc-header-right .fc-button{
            margin-bottom: 0;
        }

        .div_tr {
            margin: 0;
            padding: 10px;
        }
        table th, table td{
            text-align: center;
        }
        .layui-form-label{
            font-size: 14px;
        }
        .layui-form-item .layui-input-inline{
            width: 84%;
            margin-right: 0px;
        }
        .layui-input-block{
            width: 84%;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
</head>
<body style="font-family: 微软雅黑;">
<div class="head w clearfix">
    <div class="colorClass">
        <a href="javascript:;" style="background-color: rgb(58, 135, 173);"></a>
        <span><fmt:message code="meet.th.PendingApproval" /></span>
        <a href="javascript:;" style="background-color: rgb(105, 240, 164);"></a>
        <span><fmt:message code="meet.th.Ratified" /></span>
        <a href="javascript:;" style="background-color: rgb(255, 136, 124);"></a>
        <span><fmt:message code="meet.th.HaveHand" /></span>
        <a href="javascript:;" style="background-color: rgb(245, 181, 46);"></a>
        <span><fmt:message code="meet.th.unratified" /></span>
        <a href="javascript:;" style="background-color: rgb(219, 173, 255);"></a>
        <span style="margin-right: 24px"><fmt:message code="meet.th.IsOver" /></span>
    </div>

</div>
<div class="meentingDate" id="meentingDate" style="display: block;overflow-y: auto;padding: 0 18px 20px;box-sizing: border-box;">
    <div class="mainList">
    </div>
</div>
<!-- 会议申请-弹窗 -->
<div type="text/html" id="newModal" style="display: none;padding: 10px 40px 10px 0;">
    <form class="layui-form" lay-filter="newForm" id="addform">
        <div class="layui-form-item">
            <label class="layui-form-label">名称：<span style="color:red">*</span></label>
            <div class="layui-input-block">
                <input id="meetName" type="text" name="fromUnit" placeholder="请输入会议名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">主题：<span style="color:red">*</span></label>
            <div class="layui-input-block">
                <input id="subject" type="text" name="receiveUnit" placeholder="请输入会议主题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">参会人员：<span style="color:red">*</span></label>
            <div class="layui-input-block">
                <textarea name="exchangeUserId" id="Senduser" style="min-height: 80px;width: 86%;" user_id=" "   lay-verify="required" placeholder="请选择参会人员" class=" textarea exchange_user" disabled></textarea>
                <a href="javascript:;" id="exchangeUserId" class="add" style="color: blue;margin-left: 6px;">添加</a>
                <a href="javascript:;" id="clearSenduser" class="add" style="color: red;margin-top: 25px;margin-left: 10px">清空</a>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">会议室：<span style="color:red">*</span></label>
            <div class="layui-input-block">
                <select id="meetRoomId" name="unitType" class="unit_type"  lay-filter="searchSelects">

                </select>
            </div>
        </div>
        <div class="layui-form-item ">
            <label class="layui-form-label">开始时间：<span style="color:red">*</span></label>
            <div class="layui-input-inline form-inline" >
                <input  type="text" class="layui-input  form-inline" id="beginTime" placeholder="" >
            </div>

        </div>
        <div class="layui-form-item ">
            <label class="layui-form-label">结束时间：<span style="color:red">*</span></label>
            <div class="layui-input-inline form-inline" >
                <input type="text" class="layui-input form-inline" id="endTime" placeholder="" >
            </div>

        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">审批人：<span style="color:red">*</span></label>
            <div class="layui-input-block">
                <select id="managerId" name="unitType" class="unit_type" lay-filter="aihao">

                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <div style="display: inline">
                <span style="margin-left: 30px;">提前进入会议室时间<input id="advanceMin" type="text"  placeholder="" autocomplete="off" style="width: 40px;margin-left: 5px"></span>
                <%--<div class="layui-input-block ">--%>
                <%--<input id="meetTime" type="text"  placeholder="" autocomplete="off" class="layui-input" style="width: 40px">--%>
                <%--</div>--%>
                <span style="margin-left: 0px;margin-top: 0px">分钟</span>
            </div>
        </div>
        <div class="layui-form-item " style="margin-bottom: 10px">
            <label class="layui-form-label" style="width: 84px;padding: 9px 6px">通知审批人：</label>
            <div class="layui-input-block" style="height: 10px">
                <input  id="smsRemind" type="checkbox"  name="smstype" value="1" title="发送事务提醒消息"  lay-skin="primary" checked>
                <input id="smsRemind1"  type="checkbox"  name="smstype" value="0" title="使用手机短信提醒" lay-skin="primary">
            </div>
        </div>
        <div class="layui-upload">
            <div id="demo2" style="padding-left: 89px;"></div>
            <label class="layui-form-label">附件：</label>
            <button type="button" class="layui-btn layui-btn-primary layui-btn layui-btn-sm" id="test3" style="border: 0px;color:#1E9FFF;padding: 0;margin-top: 4px;"><img style="margin-right:5px;" src="/img/icon_uplod.png"><i class="layui-icon" style="display: none;"></i>附件上传</button>
        </div>
        <div class="layui-form-item " style="margin-top: 20px;">
            <label class="layui-form-label">会议描述：</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" class="layui-textarea" id="meetDesc"></textarea>
            </div>

        </div>
    </form>
</div>
<script>
    var dept_id='';
    var priv_id='';
    var user_id='';
    var laydate = layui.laydate;
    var form = layui.form;
    var layer = layui.layer;
    var upload = layui.upload;
    //附件
    upload.render({
        elem: '#test3'
        ,url: '/upload?module=meeting' //上传接口
        ,accept: 'file' //普通文件
        ,done: function(res){
            layer.msg('上传成功');
            var data=res.obj[0];
            var fileExtension=data.attachName.substring(data.attachName.lastIndexOf(".")+1,data.attachName.length);//截取附件文件后缀
            var attName = encodeURI(data.attachName).replace(/\+/g, "%2b").replace(/\@/g,"%40").replace(/\#/g,"%23").replace(/\&/g,"%26").replace(/\//g,"%2F").replace(/\?/g,"%3F").replace(/\￥/g,"%ef%bf%a5").replace(/\$/g,"%24").replace(/\！/g,"%ef%bc%81").replace(/\（/g,"%ef%bc%88").replace(/\）/g,"%ef%bc%89").replace(/\…/g,"%e2%80%a6%e2%80%a6");
            var fileExtensionName=attName.substring(0,attName.lastIndexOf("."));
            var deUrl = data.attUrl.split('&ATTACHMENT_NAME=')[0]+"&ATTACHMENT_NAME="+fileExtensionName+"."+fileExtension+"&FILESIZE="+data.size;
            var str = '<div id="dechs" class="dech" style="padding: 3px 0;" deUrl="' + deUrl+ '"><a href="/download?'+encodeURI(deUrl)+'" NAME="' + data.attachName + '*"><img style="margin-top: -3px; margin-right: 3px;margin-left: 20px;" src="/img/attachment_icon.png"/>' + data.attachName + '</a><img class="deImgs" style="margin-left:5px;cursor: pointer;" src="/img/file/icon_deletecha_03.png"/><input type="hidden" data-attachname="'+data.attachName+'" class="inHidden" value="' + data.aid + '@' + data.ym + '_' + data.attachId + ',"></div>';

            $('#demo2').append(str);
        }
    });
    $("#exchangeUserId").click(function(){//选人员控件
        user_id='Senduser';
        $.popWindow("../common/selectUser");
    });
    $('#clearSenduser').click(function(){
        $('#Senduser').get(0).setAttribute('user_id', '');
        $('#Senduser').val('');
    });
    //初始化申请管理员下拉列表
    $(function(){
        autoIDheight('meentingDate',46);
        windowReload();
        $('.mainList').fullCalendar({
            header: {
                left: 'prev,next,today',
                center: 'title',
                right: 'month,agendaWeek'
            },
            buttonText:{
                today:'<fmt:message code="meet.th.JumpthDay" />'
            },
            lang: 'zh-cn',
            editable: true,
            events: function(start,end,timezone, callback) {
                var date = this.getDate().format('YYYY-MM');
                $.ajax({
                    url: '/HSTmeeting/hstMeetingView',
                    dataType: 'json',
                    data: {
                        date: date
                    },
                    success: function(res) { // 获取当前月的数据
                        var datas=res.obj;
                        var events = [];
                        var TColor='';
                        var BColor='';
                        for(var i=0;i<datas.length;i++){
                            var arr=datas[i].startTime.split(' ');
                            if(datas[i].meetStatus == 1){
                                BColor='rgb(58, 135, 173)';
                            }else if(datas[i].meetStatus == 2){
                                BColor='rgb(105, 240, 164)';
                            }else if(datas[i].meetStatus == 3){
                                BColor='rgb(255, 136, 124)';
                            }else if(datas[i].meetStatus == 4){
                                BColor='rgb(245, 181, 46)';
                            }else if(datas[i].meetStatus == 5){
                                BColor='rgb(219, 173, 255)';
                            }
                            events.push({
                                id:datas[i].meetingId,
                                title: arr[1]+'  '+datas[i].meetName,
                                start: arr[0] , // will be parsed
                                textColor: '#fff',
                                backgroundColor:BColor
                            });
                        }
                        callback(events);
                    }
                });
            },
            dayClick:function(date, allDay, jsEvent, view){
                layer.open({
                    type: 1,
                    title: '好视通视频会议申请',
                    content: $('#newModal'),
                    maxmin: true,
                    area: ['60%', '85%'],
                    btn: ['确认', '取消'],
                    success:function(){
                        laydate.render({
                            elem: '#beginTime'
                            ,type: 'datetime'
                            ,trigger:'click'
                        });
                        laydate.render({
                            elem: '#endTime'
                            ,type: 'datetime'
                            ,trigger:'click'
                            ,done: function(value, date, endDate){
                                //判断会议室是否被占用
                                $.get('/HSTmeeting/judgeMeeting',{
                                    roomId:$('#meetRoomId').val(),
                                    startTime:$('#beginTime').val(),
                                    endTime:value
                                },function(res){
                                    if(res.code==1){
                                        $.layerMsg({content: res.msg, icon: 0})
                                        return false
                                    }
                                })
                            }
                        });

                        $.ajax({
                            url: '/hstMeetingRoom/getAllMeetRoomAll',
                            type: 'get',
                            dataType: 'json',
                            success: function (res) {
                                var data=res.obj;
                                var str='';
                                var roomIds=data[0].roomId
                                for(var i=0;i<data.length;i++){
                                    str+='<option value="'+data[i].roomId+'">'+data[i].roomName+'</option>';
                                }
                                $("#meetRoomId").append(str);
                                form.render();
                                $.ajax({
                                    url: '/hstMeetingRoom/selectMeetRoomManager',
                                    type: 'get',
                                    dataType: 'json',
                                    data: {
                                        roomId:roomIds,
                                    },
                                    success: function (res) {
                                        var data = res.obj1;
                                        var str2='';
                                        if(data.roomManagerNames.length>0){
                                            for(var i=0;i<data.roomManagerNames.length;i++){
                                                str2 += '<option value="' +data.roomManagerNames[i].userId + '" >' + data.roomManagerNames[i].userName + '</option>'                                    }
                                        }else{
                                            sts2=''
                                        }
                                        $("#managerId").html(str2);
                                        form.render();

                                    }
                                });
                            }
                        });


                        form.on('select(searchSelects)', function(data){
                            $.ajax({
                                url: '/hstMeetingRoom/selectMeetRoomManager',
                                type: 'get',
                                dataType: 'json',
                                data: {
                                    roomId:data.value,
                                },
                                success: function (res) {
                                    var data = res.obj1;
                                    var str2='';

                                    if(data.roomManagerNames.length>0){
                                        for(var i=0;i<data.roomManagerNames.length;i++){
                                            str2 += '<option value="' +data.roomManagerNames[i].userId + '" >' + data.roomManagerNames[i].userName + '</option>'                                    }
                                    }else{
                                        sts2='<option value="" selected></option>'
                                    }
                                    $("#managerId").html(str2);
                                    form.render();

                                }
                            });
                        });


                    }
                    ,yes: function(index){
                        var attachmentId = '';
                        var attachmentName = '';
                        var $attachments = $('#demo2').find('input[type="hidden"]');
                        $attachments.each(function(){
                            attachmentId += $(this).val();
                            attachmentName += $(this).data('attachname') + ',';
                        });


                        var smsRemind=0;
                        if($('#smsRemind').is(':checked')){
                            smsRemind=1;
                        }

                        var smsRemindd=0;
                        if($('#smsRemind1').is(':checked')){
                            smsRemindd=1;
                        }


                        var paraData = {

                            meetName: $("#meetName").val(),
                            subject: $("#subject").val(),
                            startTime: $("#beginTime").val(),
                            endTime: $("#endTime").val(),
                            userIds:  $('#Senduser').get(0).getAttribute('user_id'),
                            smsRemind: smsRemind,
                            smsRemind2: smsRemindd,
                            meetDesc: $("#meetDesc").val(),
                            managerId: $("#managerId").val()+',',
                            RoomId: $("#meetRoomId").val(),
                            attachmentId:attachmentId,
                            attachmentName:attachmentName,
                            advanceMin:$("#advanceMin").val(),

                        }

                        var meetName = $("#meetName").val();
                        var subject = $("#subject").val();
                        var startTime = $("#beginTime").val();
                        var endTime = $("#endTime").val();
                        var userIds = $("#Senduser").val();

                        if(meetName=='' || subject=='' || startTime=='' || endTime=='' || userIds==''){
                            alert('带*号为必填项！')
                        }

                        if(meetName!='' && subject!='' && startTime!='' && endTime!='' && userIds!='' && endTime < startTime){
                            alert('会议结束时间必须大于开始时间！')
                        }

                        if(meetName!='' && subject!='' && startTime!='' && endTime!='' && userIds!='' && endTime > startTime){
                            $.ajax({
                                url: '/HSTmeeting/insertMeeting',
                                type: 'post',
                                dataType: 'json',
                                data: paraData,
                                async: false,
                                success: function (obj) {
                                    if (obj.flag) {
                                        $.layerMsg({content: '申请成功！', icon: 1}, function () {
                                            layer.close(index);
                                            resetForm(form)
                                        })

                                    }else{
                                        alert(obj.msg);

                                    }
                                }
                            })
                        }




                    },
                    btn2: function(){
                        resetForm(form)

                    },
                    cancel: function(){
                        resetForm(form)

                    }
                })
            },
            eventClick:function(calEvent){
                console.log(calEvent)
                var meetingId=calEvent.id;
                $.ajax({
                    url:'/hstMeetingRoom/queryHstMeetingById',
                    type: "post",
                    dataType: "json",
                    data:{meetId:meetingId},
                    success:function (res) {
                        var data=res.object
                        layer.open({
                            type: 1,
                            title: '会议详情',
                            shade: 0.5,
                            area: ['50%', '80%'],
                            content:'<form class="layui-form" id="ajaxforms" lay-filter="formsTest" style="width:90%;margin-left:5%;margin-top: 3%;">' +
                                '<table class="layui-table">\n' +
                                '  <tbody>\n' +
                                /*  '    <tr>\n' +
                                  '      <td nowrap="nowrap" style="width:20%">会议室名称:</td>\n' +
                                  '      <td class="roomName">' +data.roomName+
                                  '</td>\n' +
                                  '    </tr>\n' +*/
                                '    <tr>\n' +
                                '      <td nowrap="nowrap" style="width:20%">会议名称:</td>\n' +
                                '      <td class="meetName">'+data.meetName+'</td>\n' +
                                '    </tr>\n' +
                                '    <tr>\n' +
                                '      <td nowrap="nowrap">会议主题:</td>\n' +
                                '      <td class="subject">'+data.subject+'</td>\n' +
                                '    </tr>\n' +
                                '    <tr>\n' +
                                '      <td nowrap="nowrap">参会人员:</td>\n' +
                                '      <td class="userIdsName">'+data.userIdsName.substring(0,data.userIdsName.length-1)+'</td>\n' +
                                '    </tr>\n' +
                                '    <tr>\n' +
                                '      <td nowrap="nowrap">开始时间:</td>\n' +
                                '      <td class="startTime">'+data.startTime+'</td>\n' +
                                '    </tr>\n' +
                                '    <tr>\n' +
                                '      <td nowrap="nowrap">结束时间:</td>\n' +
                                '      <td class="endTime">'+data.endTime+'</td>\n' +
                                '    </tr>\n' +
                                '    <tr>\n' +
                                '      <td nowrap="nowrap">审批人:</td>\n' +
                                '      <td class="managerIdName">'+data.managerIdName.substring(0,data.managerIdName.length-1)+'</td>\n' +
                                '    </tr>\n' +
                                '    <tr>\n' +
                                '      <td nowrap="nowrap">提前进入会议室时间:</td>\n' +
                                '      <td class="advanceMin">'+function () {
                                    if(data.advanceMin==0){
                                        return  '按时进入会议'
                                    }else {
                                        return data.advanceMin+'分钟'
                                    }
                                }()+'</td>\n' +
                                '    </tr>\n' +
                                '    <tr>\n' +
                                '      <td nowrap="nowrap">附件:</td>\n' +
                                '      <td class="Table">'+function () {
                                    /* var arrAttach2 = res.object.attachmentList;
                                     var stra2 = '';
                                     if (arrAttach2 && arrAttach2.length > 0){
                                         for(var i=0;i<arrAttach2.length;i++){
                                             stra2+= '<div class="dech" style="max-width: 550px;" deUrl="' + encodeURI(arrAttach2[i].attUrl)+ '"><a title="'+ arrAttach2[i].attachName +'" style="display:inline-block;width:100%;overflow: hidden; word-break:break-all;white-space: nowrap;text-overflow: ellipsis;" href="<%=basePath %>download?'+encodeURI(arrAttach2[i].attUrl)+'" NAME="' + arrAttach2[i].attachName + '*"><img style="margin-right:10px;" src="../img/attachment_icon.png"/>' + arrAttach2[i].attachName + '</a></div>';
                                            }
                                        } else {
                                            stra2='无附件';
                                        }
                                        return stra2*/

                                }()+'</td>\n' +
                                '    </tr>\n' +
                                '    <tr>\n' +
                                '      <td nowrap="nowrap">会议描述:</td>\n' +
                                '      <td class="meetDesc">'+data.meetDesc+'</td>\n' +
                                '    </tr>\n' +
                                '  </tbody>\n' +
                                '</table>'+
                                '</form>',
                            success:function(){
                                var arr=res.object.attachmentList
                                attachmentShow_news(arr,$('.Table'));
                                for(var i=0;i<$('.font_').length;i++){
                                    $('.font_').eq(i).children(":first").remove()
                                }
                                $('.font_ .file_a  span').css('margin-left','12px')
                            }
                        })
                    }
                })
            }
        });
    })

    //初始化会议室下拉列表
    function initMeetRoom(){
        $.ajax({
            url: '../../meetingRoom/getAllMeetRoom',
            type: 'get',
            dataType: 'json',
            success: function (obj) {
                var data=obj.obj;
                var str="";
                var firstRoomId;
                for(var i=0;i<data.length;i++){
                    str+='<option value="'+data[i].sid+'">'+data[i].mrName+'</option>';
                    if(i==0){
                        firstRoomId = data[i].sid;
                    }
                }
                if (str===''){
                    $("input[name='isVideo']").each(function(index,item){
                        $(this).prop("disabled",true);
                        if(index===0){
                            $(this).prop("checked",true);
                        }
                    });
                }
                str+="<option value='0'>视频会议</option>";
                $(".meetRoomId").html(str);
                //initManager(firstRoomId);
            }
        });
    }

    //审批管理员
    function initManager(roomId,managerId){
        $.ajax({
            url: '/meeting/getManagers',
            type: 'get',
            dataType: 'json',
            data: {
                paraName:"MEETING_MANAGER_TYPE",
                roomId:roomId
            },
            success: function (obj) {
                var data=obj.object;
                var managerArray=data.usersList;
                var str="";
                for(var i=0;i<managerArray.length;i++){
                    if(managerId==undefined){
                        str+='<option value="'+managerArray[i].uid+'">'+managerArray[i].userName+'</option>';
                    }else if(managerId==managerArray[i].uid){
                        str+='<option value="'+managerArray[i].uid+'" selected>'+managerArray[i].userName+'</option>';
                    }
                }
                $(".managerId").html(str);
            }
        });
    }

    function  DateNextDay(d2) {
        //slice返回一个数组
        var str = d2.slice(5) + "-" + d2.slice(0,4);
        var d = new Date(str);
        var d3 = new Date(d.getFullYear(),d.getMonth(),d.getDate()+1);
        var month=returnMonth(d3.getMonth());
        var day=d3.getDate();
        day=day < 10? "0"+day:day;
        var str2=d3.getFullYear()+"-"+month+"-"+day;
        return str2;
    }

    function returnMonth(num) {
        var str= "";
        switch(num) {
            case 0: str= "01"; break;
            case 1: str= "02"; break;
            case 2: str= "03"; break;
            case 3: str= "04"; break;
            case 4: str= "05"; break;
            case 5: str= "06"; break;
            case 6: str= "07"; break;
            case 7: str= "08"; break;
            case 8: str= "09"; break;
            case 9: str= "10"; break;
            case 10: str= "11"; break;
            case 11: str= "12"; break;
        }
        return str;
    }
    function week_select() {
        $('.WEEKEND').hide();

        var x = $('#cycleStartDate').val();
        y = x.replace(/-/, ",");
        y = y.replace(/-/, "/");
        y = new Date(y);

        var z = $('#cycleEndDate').val();
        r = z.replace(/-/, ",");
        r = r.replace(/-/, "/");
        r = new Date(r);

        a = r - y;
        a= a/24/60/60/1000+1;

        if(a>6) {
            $('.WEEKEND').css('display','');
        }
        else {
            for(var i=x;i<=z;i=DateNextDay(i)) {
                i = i.replace(/-/, ",");
                i = i.replace(/-/, "/");
                v = new Date(i);
                s = v.getDay();
                if(/^[-]?\d+$/.test(s)) {
                    w = "WEEKEND"+s;
                    document.getElementById(w).style.display="";
                }
            }
        }
    }
    //附件删除
    function deleteChatment(data,element){

        layer.confirm('<fmt:message code="sup.th.Delete" />？', {
            btn: ['<fmt:message code="global.lang.ok" />','<fmt:message code="depatement.th.quxiao" />'], //按钮
            title:"<fmt:message code="notice.th.DeleteFile" />"
        }, function(){
            //确定删除，调接口
            $.ajax({
                type:'get',
                url:'../delete',
                dataType:'json',
                data:data,
                success:function(res){

                    if(res.flag == true){
                        layer.msg('<fmt:message code="workflow.th.delsucess" />', { icon:6});
                        element.remove();
                    }else{
                        layer.msg('<fmt:message code="lang.th.deleSucess" />', { icon:6});
                    }
                }
            });

        }, function(index){
            layer.close(index);
        });
    }
    function resetForm(form) {
        $('#newModal').hide();
        $('.exchange_user').empty();
        $('#meetName').val('');
        $('#subject').val('');
        $('#beginTime').val('');
        $('#endTime').val('');
        $('#meetDesc').val('');
        $('#managerId').empty();
        $('#meetRoomId').empty();
        $('#Senduser').val('');
        $('#advanceMin').val('');
        $("#dechs").remove();
        $('#Senduser').get(0).setAttribute('user_id', "");
        $("#smsRemind1").prop("checked",false);

    }
</script>
</body>
</html>
